//
//  CollectManageSelectView.m
//  DaMaoMall
//
//  Created by 周影杰 on 16/7/27.
//  Copyright © 2016年 daMao-wally. All rights reserved.
//

#import "CollectManageSelectView.h"
@implementation CollectManageSelectView

-(instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
    
        [self makeUI];
    }
    return self;
}
- (void)makeUI {

    NSArray *titleArray = @[@"企业收藏",@"产品收藏"];
    for (int i = 0; i < 2; i++){
        UIButton *oprationButton = [UIFactory makeButton:titleArray[i] font:15 backColor:[UIColor whiteColor] target:self action:@selector(oprationButtonAction:)];
        [oprationButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        oprationButton.tag = i + 10;
        [self addSubview:oprationButton];
        
        oprationButton.frame = CGRectMake(GetScreenWidth/2*i, 0, GetScreenWidth/2, 40);
        
        if( i == 0){
            [oprationButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            self.selectedBtn = oprationButton;
        }
    }
    
    UIView *verLine = [UIFactory makeView:[UIColor lightGrayColor]];
    [self addSubview:verLine];
    verLine.sd_layout.widthIs(0.5).heightIs(40).topSpaceToView(self,0).leftSpaceToView(self,GetScreenWidth/2);

}
- (void)oprationButtonAction:(UIButton *)sender {
    if(sender == _selectedBtn){
        return;
    }
    
    [sender setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.selectedBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _selectedBtn = sender;
    self.collectBlock(sender.tag);
}
- (void)collectManageBlock:(CollectManageBlock)aBlock {
    self.collectBlock = aBlock;
}
@end
